package com.zhongfl.crm.api.view;

import com.github.pagehelper.PageInfo;
import com.zhongfl.crm.model.LxChannel;
import com.zhongfl.crm.request.LxChannelRequest;
import com.zhongfl.crm.service.LxChannelService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import tech.heptagram.core.common.rest.ResponseResult;

/**
 * 励销渠道controller
 *
 * @author 犬冢牙
 * 2018/9/21 10:23
 */
@RestController
@RequestMapping("/lxChannel")
public class LxChannelController {

    @Resource
    private LxChannelService lxChannelService;

    /**
     * 分页查询所有数据
     * @param request
     * @return
     */
    @PostMapping("/findAllLxChannelByPage")
    public ResponseResult<PageInfo<LxChannel>> findAllLxChannelByPage(@RequestBody LxChannelRequest request){
        return new ResponseResult<>(new PageInfo<>(lxChannelService.findAllLxChannelByPage(request)));
    }

    /**
     * 按lxId查询一条数据
     * @param lxId
     * @return
     */
    @GetMapping("/findLxChannelById")
    public ResponseResult<LxChannel> findLxChannelById(@RequestParam("lxId") Long lxId){
        return new ResponseResult<>(lxChannelService.selectByLxId(lxId));
    }

    /**
     * 更新一条数据
     * @param lxChannel
     */
    @PostMapping("/updateLxChannel")
    public void updateLxChannel(@RequestBody LxChannel lxChannel){
        lxChannelService.updateByLxId(lxChannel);
    }
}
